
import 'package:json_annotation/json_annotation.dart';

import '../../../util/DateUtil.dart';
import '../base/Req.dart';
import '../base/Resp.dart';

part 'Login.g.dart';

@JsonSerializable()
class LoginReq extends TenantReq {
  String userId;
  String password;
  String machineCode;

  LoginReq({required this.userId, required this.password, required this.machineCode, required super.tenantCode,
    required super.terminalType});

  factory LoginReq.fromJson(Map<String, dynamic> json) => _$LoginReqFromJson(json);

  Map<String, dynamic> toJson() => _$LoginReqToJson(this);
}

@JsonSerializable()
class LoginResp extends OkResp {
  String userId;
  String tenantCode;
  DateTime serverDateTime;         // 服务器时间
  String authToken;                // 认证token （重连密钥）
  String token;                    // 无秘登录密钥
  int authCode;

  LoginResp({required this.userId, required this.tenantCode, required this.serverDateTime, required this.authCode,
    required this.token, required this.authToken,
    required super.coder, required super.successDataTime, super.localSeq});


  factory LoginResp.fromJson(Map<String, dynamic> json) => _$LoginRespFromJson(json);

  Map<String, dynamic> toJson() => _$LoginRespToJson(this);
}

@JsonSerializable()
class ReConnection extends TenantReq {
  final String authToken;

  ReConnection({required this.authToken, required super.tenantCode, required super.terminalType});

  factory ReConnection.fromJson(Map<String, dynamic> json) => _$ReConnectionFromJson(json);

  Map<String, dynamic> toJson() => _$ReConnectionToJson(this);
}

@JsonSerializable()
class LoginTokenReq extends TenantReq {
  String userId;
  String token;
  String machineCode;

  LoginTokenReq({required this.userId, required this.token, required this.machineCode, required super.tenantCode,
    required super.terminalType});

  factory LoginTokenReq.fromJson(Map<String, dynamic> json) => _$LoginTokenReqFromJson(json);

  Map<String, dynamic> toJson() => _$LoginTokenReqToJson(this);
}

@JsonSerializable()
class ExitReq extends TenantReq {
  String? exitMessage;

  ExitReq({required super.tenantCode, required super.terminalType});

  Map<String, dynamic> toJson() => _$ExitReqToJson(this);
}

@JsonSerializable()
class ResetSlidePasswordReq extends TenantReq {
  String userId;
  String password;

  ResetSlidePasswordReq({required this.userId, required this.password,
    required super.tenantCode, required super.terminalType});

  Map<String, dynamic> toJson() => _$ResetSlidePasswordReqToJson(this);
}